import SwiftUI

struct ProviderRow: View {
    let provider: ModelProvider
    
    var body: some View {
        HStack(spacing: 12) {
            // 图标
            ZStack {
                Rectangle()
                    .fill(Color(red: 0.95, green: 0.95, blue: 0.95))
                    .frame(width: 40, height: 40)
                    .cornerRadius(6)
                
                Image(systemName: getSystemImageName(for: provider.name))
                    .resizable()
                    .scaledToFit()
                    .frame(width: 24, height: 24)
                    .foregroundColor(getColor(for: provider.name))
            }
            
            // 名称和描述
            VStack(alignment: .leading, spacing: 2) {
                Text(provider.name)
                    .font(.subheadline)
                    .fontWeight(.medium)
                
                Text(provider.description)
                    .font(.caption)
                    .foregroundColor(.gray)
            }
            
            Spacer()
            
            // 操作按钮
            HStack(spacing: 12) {
                Button(action: {}) {
                    Text("Learn more")
                        .font(.caption)
                        .foregroundColor(.blue)
                }
                
                Button(action: {}) {
                    Text("Configure")
                        .font(.caption)
                        .padding(.horizontal, 12)
                        .padding(.vertical, 6)
                        .background(Color.blue)
                        .foregroundColor(.white)
                        .cornerRadius(4)
                }
            }
        }
    }
    
    // 根据提供商名称获取系统图标
    private func getSystemImageName(for provider: String) -> String {
        switch provider {
        case "OpenAI":
            return "sparkles"
        case "Anthropic":
            return "person.fill"
        case "Ollama":
            return "cube.fill"
        case "Azure":
            return "cloud.fill"
        case "Composio":
            return "bolt.fill"
        case "LM Studio":
            return "server.rack"
        default:
            return "questionmark"
        }
    }
    
    // 根据提供商名称获取颜色
    private func getColor(for provider: String) -> Color {
        switch provider {
        case "OpenAI":
            return .green
        case "Anthropic":
            return .purple
        case "Ollama":
            return .orange
        case "Azure":
            return .blue
        case "Composio":
            return .black
        case "LM Studio":
            return .indigo
        default:
            return .gray
        }
    }
} 